//
//  DYReleaseHeadlinesVC.m
//  kafuMerchant
//
//  Created by 帝云科技 on 2018/9/25.
//  Copyright © 2018年 帝云科技. All rights reserved.
//

#import "DYReleaseHeadlinesVC.h"
#import "DYAddBranchShopCell.h"
#import "DYShopDecorateCell.h"
#import "DYReleaseHeadlinesCell.h"
#import "DYShopHeadlinesDetailWebVC.h"
#import "DYShopCardSetFooterView.h"

@interface DYReleaseHeadlinesVC ()

@property (nonatomic,strong)DYShopCardSetFooterView *footerView;
@property (nonatomic,strong)NSArray *titleArray;
@property (nonatomic,strong)NSArray *placeHolderArray;

@end


@implementation DYReleaseHeadlinesVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title=@"发布头条";
    [self createRightBarItem:nil titleString:@"预览"];
    UIButton *rightBtn=self.navigationItem.rightBarButtonItem.customView;
    [rightBtn setTitleColor:[UIColor xhq_content] forState:UIControlStateNormal];
}
-(void)rightClick
{
    DYShopHeadlinesDetailWebVC *vc=[[DYShopHeadlinesDetailWebVC alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
-(void)dy_initData
{
    [super dy_initData];
    
    self.titleArray=@[@"头条标题",@"所属分类",@"缩略图片",@"内容简介",@"头条内容"];
    self.placeHolderArray=@[@"请输入头条标题",@"请选择所属分类",@"",@"请输入内容简介...",@"请输入头条内容..."];
}
-(void)dy_initUI
{
    [super dy_initUI];
    
    self.tableView.backgroundColor=WhiteColor;
    
    [self.tableView registerClass:[DYAddBranchShopCell
                                   class] forCellReuseIdentifier:@"DYAddBranchShopCell"];
    [self.tableView registerClass:[DYShopDecorateCell
                                   class] forCellReuseIdentifier:@"DYShopDecorateCell"];
    [self.tableView registerClass:[DYReleaseHeadlinesCell
                                   class] forCellReuseIdentifier:@"DYReleaseHeadlinesCell"];
    
    self.tableView.tableFooterView=self.footerView;
    self.tableView.showsVerticalScrollIndicator=NO;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row==2) {
        return BILIHEIGHT(100);
    }else if (indexPath.row==3||indexPath.row==4){
        return BILIHEIGHT(180);
    }
    return BILIHEIGHT(58);
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row==2) {
        DYShopDecorateCell *cell=[tableView dequeueReusableCellWithIdentifier:@"DYShopDecorateCell" forIndexPath:indexPath];
        cell.titleLabel.text=self.titleArray[indexPath.row];
        cell.imageNumber=1;
        cell.hideSeparatorLabel=NO;
        //        @weakify(self);
        cell.imageBlock = ^(NSMutableArray *imageArray) {
            //            @strongify(self);
            //           self.shopLogoArray=imageArray;
            //            [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:indexPath.row inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
        };
        
        return cell;
    }else if (indexPath.row==3||indexPath.row==4){
        DYReleaseHeadlinesCell *cell=[tableView dequeueReusableCellWithIdentifier:@"DYReleaseHeadlinesCell" forIndexPath:indexPath];
        cell.titleLabel.text=self.titleArray[indexPath.row];
        cell.hideSeparatorLabel=YES;
//        cell.infoTextView.dy_placeHolder=self.placeHolderArray[indexPath.row];
        return cell;
    }
    DYAddBranchShopCell *cell=[tableView dequeueReusableCellWithIdentifier:@"DYAddBranchShopCell" forIndexPath:indexPath];
    cell.titleLabel.text=self.titleArray[indexPath.row];
    cell.textField.placeholder=self.placeHolderArray[indexPath.row];
    if (indexPath.row==1) {
        cell.arrowImageView.hidden=NO;
        cell.textField.enabled=NO;
    }else{
        cell.arrowImageView.hidden=YES;
        cell.textField.enabled=YES;
    }
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row==1) {
        XHQHUDTEXT(@"请选择所属分类");
    }
}
-(DYShopCardSetFooterView *)footerView
{
    if (!_footerView) {
        _footerView=[[DYShopCardSetFooterView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, BILIHEIGHT(80))];
        [_footerView.submitButton setTitle:@"确认发布" forState:UIControlStateNormal];
    }
    return _footerView;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
